//
//  LJJGoodsBottomImageView.m
//  shopTest
//
//  Created by 梁佳佳 on 2016/11/18.
//  Copyright © 2016年 梁佳佳. All rights reserved.
//

#import "LJJGoodsBottomImageView.h"
#import "LJJDetailImageModel.h"

@implementation LJJGoodsBottomImageView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
    }
    return self;
}

- (void)setImageArray:(NSArray *)imageArray
{
    _imageArray = imageArray;
    CGFloat height = 0.0;
    for (LJJDetailImageModel *imageModel in imageArray) {
        if ([imageModel.ImgType isEqualToString:@"1"]) {
            NSArray *sizeArray = [imageModel.Resolution componentsSeparatedByString:@"*"];
            CGFloat imageHeight = [sizeArray[1] floatValue] / [sizeArray[0] floatValue] * WIDTH;
            UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, height, WIDTH, imageHeight)];
            [imageView sd_setImageWithURL:[NSURL URLWithString:imageModel.ImgView]];
            [self addSubview:imageView];
            height = height + imageHeight;
        }
    }
    if (_heightBlock) {
        _heightBlock(height);
    }
}

@end
